//
//  RootViewController.m
//  Yingzhi
//
//  Created by Maxwell Rose on 15/9/1.
//  Copyright (c) 2015年 yingzhi. All rights reserved.
//

#import "RootViewController.h"
#import "TabBarController.h"
#import "GuidePagesViewController.h"
@interface RootViewController ()
//@property (strong, nonatomic) TabBarController *tabBarVC;
@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
//    引导界面是否显示
//    获取版本号
    NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
    NSString *versionNum =[infoDict objectForKey:@"CFBundleShortVersionString"];
    NSLog(@" %d | %s | %@",__LINE__,__FUNCTION__,versionNum);
    
    NSString *curVersioin = [[NSUserDefaults standardUserDefaults]objectForKey:@"FirstLanding"];
    //    保存版本号
    [[NSUserDefaults standardUserDefaults]setObject:versionNum forKey:@"FirstLanding"];
    
    if(curVersioin){
        //不是第一次打开应用
        if(![curVersioin isEqualToString:versionNum]){
            //如果是新版本
            [self showGuidePagesController];
        }else{
            //不是新版本
            [self showRootViewController];
        }
    }
    else{
        //第一次打开应用
        [self showGuidePagesController];
    }

}

- (void)showGuidePagesController{
    GuidePagesViewController *guidePagesVC = [[GuidePagesViewController alloc]init];
    [self presentViewController:guidePagesVC animated:FALSE completion:nil];
}

- (void)showRootViewController{
    TabBarController *_tabBarVC = [[TabBarController alloc]init];
    [self presentViewController:_tabBarVC animated:FALSE completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
